package metrics

import (
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promauto"
)

var (
	RequestsTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "http_requests_total",
			Help: "Total number of HTTP requests by status code and method",
		},
		[]string{"code", "method"},
	)

	RequestDuration = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "http_request_duration_seconds",
			Help:    "HTTP request duration in seconds",
			Buckets: prometheus.DefBuckets,
		},
		[]string{"code", "method"},
	)

	ActiveConnections = promauto.NewGauge(
		prometheus.GaugeOpts{
			Name: "http_active_connections",
			Help: "Number of active HTTP connections",
		},
	)

	// HTTP/3 specific metrics
	HTTP3PacketLoss = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "http3_packet_loss_total",
			Help: "Total number of HTTP/3 packet loss events",
		},
		[]string{"stream_id"},
	)

	HTTP3RetransmissionLatency = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "http3_retransmission_latency_seconds",
			Help:    "HTTP/3 packet retransmission latency in seconds",
			Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1},
		},
		[]string{"stream_id"},
	)

	HTTP3StreamsActive = promauto.NewGauge(
		prometheus.GaugeOpts{
			Name: "http3_active_streams",
			Help: "Number of active HTTP/3 streams",
		},
	)

	HTTP3ConnectionErrors = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "http3_connection_errors_total",
			Help: "Total number of HTTP/3 connection errors",
		},
		[]string{"error_type"},
	)
)
